package com.codeoss.module.stock.service.impl;

import java.math.BigDecimal;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.codeoss.framework.service.impl.BaseService;
import com.codeoss.module.stock.dao.StockMovementConfirmLineMapper;
import com.codeoss.module.stock.model.StockMovementConfirm;
import com.codeoss.module.stock.model.StockMovementConfirmLine;
import com.codeoss.module.stock.model.StockMovementLine;
import com.codeoss.module.stock.service.IStockMovementConfirmLineService;

@Service
public class StockMovementConfirmLineService
		extends BaseService<StockMovementConfirmLineMapper, StockMovementConfirmLine>
		implements IStockMovementConfirmLineService {

	@Override
	@Transactional
	public StockMovementConfirmLine createConfirmLine(StockMovementConfirm stockMovementConfirm,
			StockMovementLine stockMovementLine) {
		// TODO Auto-generated method stub
		StockMovementConfirmLine stockMovementConfirmLine=new StockMovementConfirmLine();
		stockMovementConfirmLine.setStockMovementConfirmId(stockMovementConfirm.getId());
		stockMovementConfirmLine.setStockMovementLineId(stockMovementLine.getId());
		stockMovementConfirmLine.setProductProductId(stockMovementLine.getProductProductId());
		stockMovementConfirmLine.setProductAttrSetInstanceId(stockMovementLine.getProductAttrSetInstanceId());
		stockMovementConfirmLine.setTargetQty(stockMovementLine.getMovementQty());
		stockMovementConfirmLine.setConfirmedQty(stockMovementLine.getMovementQty());
		stockMovementConfirmLine.setScrappedQty(new BigDecimal(0));
		insert(stockMovementConfirmLine);
		return stockMovementConfirmLine;
	}

	@Override
	public List<StockMovementConfirmLine> getLineListByStockMovementConfirmId(Long stockMovementConfirmId) {
		// TODO Auto-generated method stub
		QueryWrapper<StockMovementConfirmLine> query=new QueryWrapper<StockMovementConfirmLine>();
		query.eq("stock_movement_confirm_id", stockMovementConfirmId);
		return list(query);
	}
}